package com.wisezone.workflow.dao.ibatis;

import java.util.List;
import java.util.Map;

import com.wisezone.common.dao.impl.BaseDaoImpl;
import com.wisezone.workflow.bean.WfActivityInstance;
import com.wisezone.workflow.bean.form.WfActivityInstanceForm;
import com.wisezone.workflow.bean.search.WfActivityInstanceSearch;
import com.wisezone.workflow.dao.WfActivityInstanceDao;
import com.wisezone.workflow.exception.WfDaoException;

/**
 * IBATIS 活动实例实现类
 * @author tss 2009-09-05
 * 
 */
public class WfActivityInstanceDaoImpl extends BaseDaoImpl implements WfActivityInstanceDao {

	
    public WfActivityInstanceDaoImpl() {
        super();
    }
    
    
    /**
     * 根据 流程实例Id和活动类型获得活动实例
     */
    public WfActivityInstance selectByType(Map<String,Object> map) throws WfDaoException {
    	
    	return this.get("selectByType", map);
    }
    
    /**
     * 根据流程实例Id 获得所有活动实例列表
     * @param processInstId
     * @return
     * @throws WfDaoException
     */
    public List<WfActivityInstanceForm> listByProcessInstId(Long processInstId) throws WfDaoException{
    
    	WfActivityInstanceSearch searchEntity = new WfActivityInstanceSearch();
    	searchEntity.setProcessInstId(processInstId);
    	List<WfActivityInstanceForm> list = this.listFormAll(searchEntity);
    	return list;
    }
      
    /**
     * 根据流程实例Id 获得该流程下最后一个活动名称
     * @param piId
     * @return
     * @throws WfDaoException
     */
    public String getLastActivityName(Long piId) throws WfDaoException{
    	
    	WfActivityInstance ai = this.get("slectLastName", piId);
    	if(ai != null){
    		return ai.getName();
    	}
    	return null;
    }
    
    /**
     * 删除当前流程实例下，相同活动名称，未开始的活动活动实例
     * @param ai
     * @throws WfDaoException
     */
    public void deleteOhter(WfActivityInstance ai) throws WfDaoException {
    	
    	this.execute("deleteOther",ai);
    }




  

    

}